package com.athena.components
{
	import flash.events.FocusEvent;
	import flash.text.TextField;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author ...
	 */
	public class TextHolder extends TextField
	{
		private var hint:String;
		
		public function TextHolder(placeholder:String, _tf : TextFormat)
		{
			super();
			defaultTextFormat = _tf;
			hint = placeholder;
			addEventListener(FocusEvent.FOCUS_IN, focusIn);
			addEventListener(FocusEvent.FOCUS_OUT, focusOut);
			text = placeholder;
			type = TextFieldType.INPUT;
			alpha = 0.7;
		}
		
		private function focusIn(evt:FocusEvent):void
		{
			if (evt.target.text == hint) {
				text = "";
				alpha = 1;
			}
		}
		
		private function focusOut(evt:FocusEvent):void
		{
			if (evt.target.text == "") {
				alpha = 0.7;
				text = hint;
			}
		}
	}

}